-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: special case the return values from a sharded first/last_over_time query #13578
Conversation
Signed-off-by: Callum Styan <callumstyan@gmail.com>
pkg/logql/engine.go
Outdated
@@ -381,9 +385,36 @@ func (q *query) evalSample(ctx context.Context, expr syntax.SampleExpr) (promql_ | |||
return nil, errors.New("unexpected empty result") | |||
} | |||
|
|||
func (q *query) JoinSampleVector(next bool, r StepResult, stepEvaluator StepEvaluator, maxSeries int) (promql_parser.Value, error) { | |||
func vectorsToSeries(vec promql.Vector) ([]promql.Series, map[uint64]*promql.Series) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a test function for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is tested via TestMappingEquivalence_Instant
, we could add a test specifically for this but it didn't feel necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and few bits of feedback mainly around tests
@@ -395,6 +426,14 @@ func (q *query) JoinSampleVector(next bool, r StepResult, stepEvaluator StepEval | |||
} | |||
|
|||
if GetRangeType(q.params) == InstantType { | |||
// an instant query sharded first/last_over_time can return a single vector | |||
if mergeFirstLast { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does TestMappingEquivalence_Instant
need a test for the false case (existing behavior) here? Or is that adequately covered elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tests here execute both the sharded and unsharded (aka not mergeFirstLast) versions of the queries, and then compare the results
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
Signed-off-by: Callum Styan <callumstyan@gmail.com>
TestMappingEquivalence Signed-off-by: Callum Styan <callumstyan@gmail.com>
…me query (grafana#13578) Signed-off-by: Callum Styan <callumstyan@gmail.com>
We noticed during the rollout of
first/last_over_time
sharding earlier this week that instant queries would return vectors only (as intended), and the code for handling merging of shardedfirst/last_over_time
queries expected to only receive matrices.With this PR we're special casing the return value from
JoinSampleVector
if the operation type is the shardedfirst/last_over_time
.